import { defHttp } from '@/utils/http';
enum API {
  queryClusterPageList = '/devops/cluster/pageList',
  querySpacePageList = '/devops/space/pageList',
  addClusterData = '/devops/cluster',
  handelSpaceData = '/devops/space',
  allClusterList = '/devops/cluster/list',
  allNamespaceList = '/devops/namespace/list',
  addNamespaceList = '/devops/namespace',
  pipelineTemplate = '/devops/pipeline-template/pageList',
  addPipelineTemplate = '/devops//pipeline-template',
  existsEnvironmentLimit = '/devops/space/existsEnvironmentLimit',
  existsSpaceLimit = '/devops//cluster/existsSpaceLimit',
}

//运维-查询集群管理列表
export const queryClusterPageListFun = (data: OperationManagement.tableParamsList) =>
  defHttp.post({ url: API.queryClusterPageList, data });

//运维-查询集群管理列表(全量)
export const queryClusterAllList = (data?: any) => defHttp.post({ url: API.allClusterList, data });

//运维-查询交付空间
export const querSpacePageListFun = (data?: any) => defHttp.post({ url: API.querySpacePageList, data });

//集群-新增集群
export const addClusterDataFun = (data?: any) => defHttp.post({ url: API.addClusterData, data });

//集群-删除集群
export const deleteClusterDataFun = (id: any) => defHttp.delete({ url: `${API.addClusterData}/${id}` });

//集群-编辑集群
export const putClusterDataFun = (data: any) => defHttp.put({ url: API.addClusterData, data });

//集群-是否存在关联交付空间限制
export const getExistsSpaceLimit = (uuid: string | number) => defHttp.get({ url: `${API.existsSpaceLimit}/${uuid}` });

//空间-新增交付空间
export const addSpaceDataFun = (data?: any) => defHttp.post({ url: API.handelSpaceData, data });

//空间-编辑交付空间
export const putSpaceDataFun = (data: any) => defHttp.put({ url: API.handelSpaceData, data });

//空间-删除交付空间
export const deleteSpaceDataFun = (id: any) => defHttp.delete({ url: `${API.handelSpaceData}/${id}` });

//空间-查询命名空间（全量）
export const querAllNameSpace = (data?: any) => defHttp.post({ url: API.allNamespaceList, data });

//空间-是否存在关联环境限制
export const getExistsEnvironmentLimit = (uuid: string | number) =>
  defHttp.get({ url: `${API.existsEnvironmentLimit}/${uuid}` });

//命名空间-新增命名空间
export const addNamespaceFun = (data?: any) => defHttp.post({ url: API.addNamespaceList, data });

//流水线模板-查询流水线模板列表(有过滤条件，可以分页)
export const getPipelineTemplate = (data?: OperationManagement.tableParamsList) =>
  defHttp.post({ url: API.pipelineTemplate, data });

// 流水线模板-删除流水线模板
export const deletePipelineTemplate = (uuid: string) =>
  defHttp.request({ url: `/devops/pipeline-template/${uuid}`, method: 'delete' });

// 获取流水线模板配置信息 uuid: 模板uuid
export const getPipelineTemplateConfig = (uuid: string) =>
  defHttp.get({ url: `/devops/pipeline-template/pipelineTemplateConfig/${uuid}` });

//流水线模板-新增流水线模板
export const addPipelineTemplate = (data?: OperationManagement.PipelineTemplateConfig) =>
  defHttp.post({ url: API.addPipelineTemplate, data });

// 流水线模板-更新流水线模板
export const updatePipelineTemplate = (data: OperationManagement.PipelineTemplateConfig) =>
  defHttp.request({ url: '/devops/pipeline-template', method: 'put', data });

// 查询工具链列表(有过滤条件，可以分页)
export const getToolChainList = (data?: OperationManagement.tableParamsList) =>
  defHttp.post({ url: '/devops/tool-chain/pageList', data });

// 复制流水线模板
export const copyPipelineTemplate = (data: any) => defHttp.post({ url: `/devops/pipeline-template/copy`, data });

// 获取我的应用列表
export const getMyAppLists = (data: any) => defHttp.post({ url: `/devops/application/myApps`, data });
